import React, {Component} from 'react';

import NavigationUtil from "../navigator/NavigationUtil";
import SplashScreen from 'react-native-splash-screen'
import actions from "../action";
import {connect} from "react-redux";

type Props = {};

class WelcomePage extends Component<Props> {
    componentDidMount() {
        console.log("WelcomePage:componentDidMount");
        this.props.onThemeInit();
        this.timer = setTimeout(() => {
            console.log("WelcomePage: SplashScreen.hide()");
            SplashScreen.hide();//在Activity代码中打开的SplashScreenDialog,在这里关闭
            NavigationUtil.goToPage(this.props,"Main")
        }, 200);
    }

    componentWillUnmount() {
        console.log("WelcomePage:componentWillUnmount");//back返回键返回后.再次启动这里不执行
        this.timer && clearTimeout(this.timer);
    }

    render() {
        return null;
    }
}
const mapDispatchToProps = dispatch => ({
    onThemeInit: () => dispatch(actions.onThemeInit()),
});

export default connect(null, mapDispatchToProps)(WelcomePage);